@extends('cms/system/admin/template/theme_default/common')
@section('page-body')
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-form layui-form-pane" id="exam-room-form" lay-filter="exam-room-form">
                    <div class="layui-form-item">
                        <label class="layui-form-label">考试名称</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="text" name="name" value="{{$data['name'] ?? ''}}" placeholder="请输入名称" autocomplete="off" lay-verify="required" required />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">评卷模式</label>
                        <div class="layui-input-block">
                            <select id="decide_mode" name="decide_mode" lay-filter="decide_mode">
                                <option value="1" {{isset($data) && $data['decide_mode'] == 1 ? 'selected' : ''}}>系统评卷</option>
                                <option value="2" {{isset($data) && $data['decide_mode'] == 2 ? 'selected' : ''}}>人工评卷</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">组卷模式</label>
                        <div class="layui-input-block">
                            <select id="make_mode" name="make_mode" lay-filter="make_mode">
                                <option value="1" {{isset($data) && $data['make_mode'] == 1 ? 'selected' : ''}}>手动抽题组卷</option>
                                <option value="2" {{isset($data) && $data['make_mode'] == 2 ? 'selected' : ''}}>题库抽题组卷</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">考试时间</label>
                        <div class="layui-input-block">
                            @php
                                $date_range = '';
                                if (isset($data) && $data['start_date'] && $data['finish_date']) {
                                    $date_range = date('Y-m-d H:i:s', strtotime($data['start_date'])).' 至 '.date('Y-m-d H:i:s', strtotime($data['finish_date']));
                                }
                            @endphp
                            <input id="start_date" class="layui-input" type="hidden" name="start_date" value="{{$data['start_date'] ?? ''}}" />
                            <input id="finish_date" class="layui-input" type="hidden" name="finish_date" value="{{$data['finish_date'] ?? ''}}" />
                            <input id="date-range" class="layui-input" type="text" value="{{$date_range}}" placeholder="年-月-日 时:分:秒 至 年-月-日 时:分:秒" autocomplete="off" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">考试时段</label>
                        <div class="layui-input-block">
                            @php
                                $time_range = '';
                                if (isset($data) && $data['start_time'] && $data['finish_time']) {
                                    $time_range = date('H:i:s', strtotime($data['start_time'])).' 至 '.date('H:i:s', strtotime($data['finish_time']));
                                }
                            @endphp
                            <input id="start_time" class="layui-input" type="hidden" name="start_time" value="{{$data['start_time'] ?? ''}}" />
                            <input id="finish_time" class="layui-input" type="hidden" name="finish_time" value="{{$data['finish_time'] ?? ''}}" />
                            <input id="time-range" class="layui-input" type="text" value="{{$time_range}}" placeholder="时:分:秒 至 时:分:秒" autocomplete="off" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">考试时长</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="text" name="duration" value="{{$data['duration'] ?? ''}}" placeholder="考试时长，不填则不限制，单位为分钟" autocomplete="off" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">卷面总分</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="number" name="score_total" value="{{$data['score_total'] ?? ''}}" placeholder="为空则自动计算组题分数" autocomplete="off" lay-verify="required" required />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <fieldset class="layui-elem-field">
                            <legend>组题规则</legend>
                            <div id="make_mode_setting" class="layui-field-box layui-form-pane"></div>
                        </fieldset>
                    </div>
                    <div class="layui-form-item">
                        @if(isset($data))
                            <input id="submit-update" class="layui-btn" type="button" value="更新" lay-submit lay-filter="submit-update" />
                        @else
                            <input id="submit-create" class="layui-btn" type="button" value="添加" lay-submit lay-filter="submit-create" />
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--手工组卷-->
    <script type="text/html" id="make_mode_1">
        <fieldset class="layui-elem-field" id="make_rule_@{{ d.id }}" data-id="@{{ d.id }}">
            <legend>
                <span>规则-@{{ d.id }}</span>
                <a class="layui-btn layui-btn-normal layui-btn-xs" data-action="createRuleItemFunc"><i class="layui-icon layui-icon-edit"></i>添加</a>
                @{{# if (d.id > 1) { }}
                <a class="layui-btn layui-btn-danger layui-btn-xs" data-action="deleteRuleItemFunc"><i class="layui-icon layui-icon-close"></i>删除</a>
                @{{# } else { }}
                <a class="layui-btn layui-btn-danger layui-btn-disabled layui-btn-xs"><i class="layui-icon layui-icon-close"></i>删除</a>
                @{{# } }}
            </legend>
            <div class="layui-field-box layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label">题型设置</label>
                    <div class="layui-input-block">
                        <select lay-filter="make_rule_@{{ d.id }}_type">
                            @foreach($topic_type as $type_k => $type_v)
                                <option value="{{$type_k}}">{{$type_v['name']}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <table id="make_mode_1_rule_@{{ d.id }}" lay-filter="make_mode_1_rule_@{{ d.id }}"></table>
            </div>
        </fieldset>
    </script>
    <!--题库组卷-->
    <script type="text/html" id="make_mode_2">
        <fieldset class="layui-elem-field" id="make_rule_@{{ d.id }}" data-id="@{{ d.id }}">
            <legend>
                <span>规则-@{{ d.id }}</span>
                <a class="layui-btn layui-btn-normal layui-btn-xs" data-action="createRuleItemFunc"><i class="layui-icon layui-icon-edit"></i>添加</a>
                @{{# if (d.id > 1) { }}
                <a class="layui-btn layui-btn-danger layui-btn-xs" data-action="deleteRuleItemFunc"><i class="layui-icon layui-icon-close"></i>删除</a>
                @{{# } else { }}
                <a class="layui-btn layui-btn-danger layui-btn-disabled layui-btn-xs"><i class="layui-icon layui-icon-close"></i>删除</a>
                @{{# } }}
            </legend>
            <div class="layui-field-box layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label">题型设置</label>
                    <div class="layui-input-block">
                        <select name="setting[make][@{{ d.id }}][topic_type]" lay-filter="make_rule_@{{ d.id }}_type">
                            @foreach($topic_type as $type_k => $type_v)
                                <option value="{{$type_k}}" @{{# if(d.topic_type == '@php echo $type_k; @endphp') { }} selected @{{# } }}>{{$type_v['name']}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <table id="make_mode_2_rule_@{{ d.id }}" lay-filter="make_mode_2_rule_@{{ d.id }}"></table>
            </div>
        </fieldset>
    </script>
    <script type="text/html" id="toolbar_make_mode_rule">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="ruleSelectFunc">选择</button>
        </div>
    </script>
    <script type="text/html" id="table_topic_number">
        <div>
            @{{# if (d.LAY_COL.field == 'topic_level_1_number') { }}
            <input type="hidden" name="setting[make][@{{ d.config.rule_id }}][topic_group][@{{ d.id }}][level_1][number]" value="@{{ d.config.topic_setting.level_1.number }}" />
            <div class="layui-btn layui-btn-fluid layui-btn-radius layui-btn-xs layui-btn-danger"><span class="wo-value">@{{ d.config.topic_setting.level_1.number }}</span>/@{{ d.select_single_count.level_1 }}</div>
            @{{# } }}
            @{{# if (d.LAY_COL.field == 'topic_level_2_number') { }}
            <input type="hidden" name="setting[make][@{{ d.config.rule_id }}][topic_group][@{{ d.id }}][level_2][number]" value="@{{ d.config.topic_setting.level_2.number }}" />
            <div class="layui-btn layui-btn-fluid layui-btn-radius layui-btn-xs layui-btn-danger"><span class="wo-value">@{{ d.config.topic_setting.level_2.number }}</span>/@{{ d.select_single_count.level_2 }}</div>
            @{{# } }}
            @{{# if (d.LAY_COL.field == 'topic_level_3_number') { }}
            <input type="hidden" name="setting[make][@{{ d.config.rule_id }}][topic_group][@{{ d.id }}][level_3][number]" value="@{{ d.config.topic_setting.level_3.number }}" />
            <div class="layui-btn layui-btn-fluid layui-btn-radius layui-btn-xs layui-btn-danger"><span class="wo-value">@{{ d.config.topic_setting.level_3.number }}</span>/@{{ d.select_single_count.level_3 }}</div>
            @{{# } }}
        </div>
    </script>
    <script type="text/html" id="table_topic_score">
        <div>
            @{{# if (d.LAY_COL.field == 'topic_level_1_score') { }}
            <input type="hidden" name="setting[make][@{{ d.config.rule_id }}][topic_group][@{{ d.id }}][level_1][score]" value="@{{ d.config.topic_setting.level_1.score }}" />
            <div class="layui-btn layui-btn-fluid layui-btn-radius layui-btn-xs layui-btn-primary">@{{ d.config.topic_setting.level_1.score }}</div>
            @{{# } }}
            @{{# if (d.LAY_COL.field == 'topic_level_2_score') { }}
            <input type="hidden" name="setting[make][@{{ d.config.rule_id }}][topic_group][@{{ d.id }}][level_2][score]" value="@{{ d.config.topic_setting.level_2.score }}" />
            <div class="layui-btn layui-btn-fluid layui-btn-radius layui-btn-xs layui-btn-primary">@{{ d.config.topic_setting.level_2.score }}</div>
            @{{# } }}
            @{{# if (d.LAY_COL.field == 'topic_level_3_score') { }}
            <input type="hidden" name="setting[make][@{{ d.config.rule_id }}][topic_group][@{{ d.id }}][level_3][score]" value="@{{ d.config.topic_setting.level_3.score }}" />
            <div class="layui-btn layui-btn-fluid layui-btn-radius layui-btn-xs layui-btn-primary">@{{ d.config.topic_setting.level_3.score }}</div>
            @{{# } }}
        </div>
    </script>
    <script type="text/javascript">
        layui.config({
            base: '/layui-admin/'
        }).extend({
            index: 'lib/index'
        }).use(['index', 'system'], function () {
            var topicConfig = {};
            var groupConfig = {};
            // 操作列表
            var actionList = {
                // 渲染模型设置
                modeSettingFunc: function (mode, data) {
                    // 组卷模式设置
                    var settingArea = layui.$('#make_mode_setting');
                    // 组卷设置模板
                    var template = layui.$('#make_mode_' + mode).html();
                    layui.laytpl(template).render(data, function (html) {
                        if (data.id == 1) {
                            settingArea.html(html);
                        } else {
                            settingArea.append(html);
                        }
                        // 绑定添加删除事件
                        layui.jquery('#make_rule_' + data.id).on('click', 'legend a.layui-btn', function () {
                            var action = layui.jquery(this).data('action');
                            actionList[action] ? actionList[action].call(this, mode, data) : '';
                        });

                        // 监听题型切换
                        layui.form.on('select(make_rule_' + data.id + '_type)', function (result) {
                            // console.log('题型切换：', result)
                            if (mode == 1) {
                                // 渲染规则列表
                                actionList.ruleListFunc(mode, data.id, {
                                    topic_type: result.value,
                                });
                            }
                            if (mode == 2) {
                                // 渲染规则列表
                                actionList.ruleListFunc(mode, data.id, {
                                    topic_type: result.value,
                                    topic_group: {}
                                });
                            }
                        });
                        if (mode == 1) {
                            // 渲染规则列表
                            actionList.ruleListFunc(mode, data.id, {
                                topic_type: data.topic_type
                            });
                        }
                        if (mode == 2) {
                            // 渲染规则列表
                            actionList.ruleListFunc(mode, data.id, {
                                topic_type: data.topic_type,
                                topic_group: data.topic_group
                            });
                        }
                        layui.form.render();
                    });
                },
                // 创建规则项
                createRuleItemFunc: function (mode, data) {
                    // 取得设置区域
                    var settingArea = layui.$('#make_mode_setting');
                    var ruleItemList = settingArea.children('fieldset.layui-elem-field');
                    var id = 0;
                    ruleItemList.each(function (item_k, item_v) {
                        var itemId = layui.$(item_v).data('id');
                        if (itemId >= id) {
                            id = ++itemId;
                        }
                    });
                    if (mode == 1) {
                        actionList['modeSettingFunc'].call(this, mode, {
                            id: id
                        });
                    }
                    if (mode == 2) {
                        actionList['modeSettingFunc'].call(this, mode, {
                            id: id,
                            topic_type: 'select-unset',
                            topic_group: {}
                        });
                    }
                },
                // 删除规则项
                deleteRuleItemFunc: function (mode, data) {
                    layui.jquery('#make_rule_' + data.id).remove();
                },
                // 渲染规则列表
                ruleListFunc: function (mode, id, config) {
                    console.log('渲染列表', mode, id, config)
                    var id_list = '';
                    if (config) {
                        if (mode == 2) {
                            if (!config.hasOwnProperty('topic_group')) {
                                config.topic_group = {};
                            } else {
                                id_list = Object.keys(config.topic_group).join(',');
                            }
                        }
                    }
                    // 手动抽题
                    if (mode == 1) {
                        layui.table.render({
                            elem: '#make_mode_' + mode + '_rule_' + id,
                            toolbar: '#toolbar_make_mode_rule',
                            url: layui.setter.apiLink + '/exam/admin_topic/retrieve?app_id={{$app['id'] ?? 0}}&id_list=' + id_list,
                            parseData: function (result) {
                                if (id_list) {
                                    return {
                                        code: result.code == 1 ? 0 : 1,
                                        msg: result.msg,
                                        count: result.data.total,
                                        data: result.data.items
                                    }
                                }
                                return false;
                            },
                            cols: [[
                                {type: 'checkbox', fixed: 'left'},
                                {field: 'id', width: 80, title: 'ID', sort: true},
                                {field: 'name', title: '题目名称'},
                                {field: 'group', title: '所属题库'},
                                {field: 'group', title: '难度'},
                                {field: 'group', title: '分数'},
                            ]],
                        });
                    }
                    // 题库抽题
                    if (mode == 2) {
                        layui.table.render({
                            elem: '#make_mode_' + mode + '_rule_' + id,
                            toolbar: '#toolbar_make_mode_rule',
                            url: layui.setter.apiLink + '/exam/admin_topic_group/retrieve?app_id={{$app['id'] ?? 0}}&id_list=' + id_list,
                            parseData: function (result) {
                                if (id_list) {
                                    layui.jquery.each(result.data.items, function (item_k, item_v) {
                                        result.data.items[item_k].config = {
                                            rule_id: id,
                                            topic_type: config.topic_type,
                                            topic_setting: config.topic_group[item_v.id]
                                        };
                                    });
                                    console.log('请求结果：', result)
                                    return {
                                        code: result.code == 1 ? 0 : 1,
                                        msg: result.msg,
                                        count: result.data.total,
                                        data: result.data.items
                                    }
                                }
                                return false;
                            },
                            cols: [[
                                {field: 'id', width: 60, title: 'ID', sort: true},
                                {field: 'name', title: '题库名称'},
                                {field: 'topic_level_1_number', title: '简单题量', event: 'topicLevelNumberFunc', templet: '#table_topic_number'},
                                {field: 'topic_level_1_score', title: '每题分数', event: 'topicLevelScoreFunc', templet: '#table_topic_score'},
                                {field: 'topic_level_2_number', title: '常规题量', event: 'topicLevelNumberFunc', templet: '#table_topic_number'},
                                {field: 'topic_level_2_score', title: '每题分数', event: 'topicLevelScoreFunc', templet: '#table_topic_score'},
                                {field: 'topic_level_3_number', title: '困难题量', event: 'topicLevelNumberFunc', templet: '#table_topic_number'},
                                {field: 'topic_level_3_score', title: '每题分数', event: 'topicLevelScoreFunc', templet: '#table_topic_score'},
                                {fixed: 'right', width: 80, title: '操作', align: 'center',  toolbar: '#tool-exam-room-list'}
                            ]],
                        });
                    }
                    // 绑定事件
                    layui.table.on('toolbar(make_mode_' + mode + '_rule_' + id + ')', function (object) {
                        return actionList[object.event] ? actionList[object.event].call(this, object, mode, id, config) : '';
                    });
                    layui.table.on('tool(make_mode_' + mode + '_rule_' + id + ')', function (object) {
                        return actionList[object.event] ? actionList[object.event].call(this, object, mode, id, config) : '';
                    });
                },
                ruleSelectFunc: function (object, mode, id, config) {
                    var id_list = '';
                    if (config) {
                        switch (mode) {
                            case 1: // 手动抽题
                                break;
                            case 2: // 题库抽题
                                if (config.hasOwnProperty('topic_group')) {
                                    id_list = Object.keys(config.topic_group).join(',');
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    if (mode == 1) {
                        var selectLayer = layui.system.iframeLayer({
                            sourceWindow: window,
                            targetName: 'top',
                            title: '选择',
                            content: layui.setter.mvcLink + '/exam/admin_topic/select?app_id={{$app['id'] ?? 0}}&select_multi=1&select_value=' + id_list,
                            btn: ['确定', '取消'],
                            yes: function (layerIndex, layerWindow) {
                                // 取得iframe窗口
                                var iframe = layerWindow.find('iframe')[0];
                                var selectResult = iframe.contentWindow.selectConfirm();
                                console.log('选择结果：', selectResult);
                            }
                        });
                    }
                    if (mode == 2) {
                        var selectLayer = layui.system.iframeLayer({
                            sourceWindow: window,
                            targetName: 'top',
                            title: '选择',
                            content: layui.setter.mvcLink + '/exam/admin_topic_group/select?app_id={{$app['id'] ?? 0}}&select_multi=1&select_value=' + id_list,
                            btn: ['确定', '取消'],
                            yes: function (layerIndex, layerWindow) {
                                // 取得iframe窗口
                                var iframe = layerWindow.find('iframe')[0];
                                var selectResult = iframe.contentWindow.selectConfirm();
                                // console.log('选择结果', selectResult);
                                layui.jquery.each(selectResult.data, function (index, value) {
                                    if (!config.hasOwnProperty('topic_group')) {
                                        config.topic_group = {};
                                    }
                                    if (!config.topic_group.hasOwnProperty(value.id)) {
                                        config.topic_group[value.id] = {
                                            level_1: {
                                                number: 0,
                                                score: 0,
                                            },
                                            level_2: {
                                                number: 0,
                                                score: 0,
                                            },
                                            level_3: {
                                                number: 0,
                                                score: 0,
                                            }
                                        };
                                    }
                                });
                                // 重新渲染规则列表
                                actionList.ruleListFunc(mode, id, config);
                            }
                        });
                    }
                },
                topicLevelNumberFunc: function (object, mode, id, config) {
                    console.log(this, object, mode, id, config)
                    var dom = layui.jquery(this);
                    var field = dom.data('field');
                    var value = 0;
                    if (field == 'topic_level_1_number') {
                        field = 'level_1';
                    }
                    if (field == 'topic_level_2_number') {
                        field = 'level_2';
                    }
                    if (field == 'topic_level_3_number') {
                        field = 'level_3';
                    }
                    value = object.data.config.topic_setting[field].number;
                    console.log('设置值', value)
                    layui.layer.prompt({
                        formType: 0,
                        title: '设置题量',
                        value: value
                    }, function(value, index){
                        layui.layer.close(index);
                        if (value > object.data[object.data.config.topic_type + '_count'][field]) {
                            layui.layer.msg('超出题库题目');
                            value = object.data[object.data.config.topic_type + '_count'][field];
                        }
                        object.data.config.topic_setting[field].number = value;
                        // object.update(object.data);
                        // 更新dom
                        dom.find('input').val(value);
                        dom.find('.wo-value').text(value);
                    });
                },
                topicLevelScoreFunc: function (object, mode, id, config) {
                    console.log(this, object, mode, id, config)
                    var dom = layui.jquery(this);
                    var field = dom.data('field');
                    var value = 0;
                    if (field == 'topic_level_1_score') {
                        field = 'level_1';
                    }
                    if (field == 'topic_level_2_score') {
                        field = 'level_2';
                    }
                    if (field == 'topic_level_3_score') {
                        field = 'level_3';
                    }
                    value = object.data.config.topic_setting[field].score;
                    console.log('设置值', value)
                    layui.layer.prompt({
                        formType: 0,
                        title: '设置分数',
                        value: value
                    }, function(value, index){
                        layui.layer.close(index);
                        object.data.config.topic_setting[field].score = value;
                        // object.update(object.data);
                        // 更新dom
                        dom.find('input').val(value);
                        dom.find('.layui-btn').text(value);
                    });
                },
            };

            // region 渲染时间控件 +++++
            layui.laydate.render({
                elem: '#date-range',
                type: 'datetime',
                range: '至',
                done: function (value, start, finish) {
                    // console.log(value, start, finish)
                    layui.jquery('#start_date').val(start.year + '-' + start.month + '-' + start.date + ' ' + start.hours + ':' + start.minutes + ':' + start.seconds);
                    layui.jquery('#finish_date').val(finish.year + '-' + finish.month + '-' + finish.date + ' ' + finish.hours + ':' + finish.minutes + ':' + finish.seconds);
                }
            });
            layui.laydate.render({
                elem: '#time-range',
                type: 'time',
                range: '至',
                done: function (value, start, finish) {
                    // console.log(value, start, finish)
                    layui.jquery('#start_time').val(start.hours + ':' + start.minutes + ':' + start.seconds);
                    layui.jquery('#finish_time').val(finish.hours + ':' + finish.minutes + ':' + finish.seconds);
                }
            });
            // endregion

            // 取得组卷模式
            var makeModeValue = layui.$('#make_mode').val();

            @if(!isset($data['setting']['make']))
            // 渲染默认数据
            actionList['modeSettingFunc'].call(this, makeModeValue, {
                id: 1,
                topic_type: 'select_single'
            });
            @else
                var makeConfig = @json($data['setting']['make']);
                layui.jquery.each(makeConfig, function (make_k, make_v) {
                    // console.log(make_k, make_v)
                    actionList['modeSettingFunc'].call(this, makeModeValue, {
                        id: make_k,
                        topic_type: make_v.topic_type,
                        topic_group: make_v.topic_group,
                    });
                });
            @endif

            // region 组卷方式切换 +++++
            layui.form.on('select(make_mode)', function (data) {
                actionList['modeSettingFunc'].call(this, data.value, {id: 1});
            });
            // endregion

            // 创建
            layui.form.on('submit(submit-create)', function (data) {
                // 获取提交的字段
                var formField = data.field;
                // formField.content = layui.layedit.getContent(layuiEdit);
                console.log('表单字段：', formField);
                // ajax提交
                layui.$.ajax({
                    url: layui.setter.apiLink + '/exam/admin_room/create?app_id={{$app['id'] ?? 0}}',
                    type: 'POST',
                    data: formField,
                    success: function (result) {
                        if (result.code != 1) {
                            top.layui.layer.alert(result.msg);
                            return false;
                        }
                        var page = top.layui.admin.tabsBody(top.layui.admin.tabsPage.index).find('.layadmin-iframe');
                        console.log('调用页面：', page);
                        page[0].contentWindow.layui.table.reload('exam-room-list');
                        // 关闭弹层
                        top.layui.layer.close(layerIndex);
                    }
                });
            });
            // 更新
            layui.form.on('submit(submit-update)', function (data) {
                // 获取提交的字段
                var formField = data.field;
                console.log('表单字段：', formField);
                // ajax提交
                layui.$.ajax({
                    url: layui.setter.apiLink + '/exam/admin_room/update?app_id={{$app['id'] ?? 0}}&id={{$data['id'] ?? 0}}',
                    type: 'POST',
                    data: formField,
                    success: function (result) {
                        if (result.code != 1) {
                            top.layui.layer.alert(result.msg);
                            return false;
                        }
                        var page = top.layui.admin.tabsBody(top.layui.admin.tabsPage.index).find('.layadmin-iframe');
                        console.log('调用页面：', page);
                        page[0].contentWindow.layui.table.reload('exam-room-list');
                        // 关闭弹层
                        top.layui.layer.close(layerIndex);
                    }
                });
            });
        });
    </script>
@endsection